﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public void MapICC_ABAUFM(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void SaveICC_ABAUFM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            switch (ITXDBVERSION)
            {
                case "JLT":
                    Result = QueryICC_ABAUFM(dwData);
                    if (Result.Tables.Count > 0)
                    {
                        tbLocal = Result.Tables[0];
                        if (tbLocal.Rows.Count > 0)
                        {
                            flgExist = true;
                            dwLocal = tbLocal.Rows[0];
                        }
                        else
                        {
                            dwLocal = tbLocal.NewRow();
                        }
                    }

                    MapICC_ABAUFM(ref dwLocal, dwData);

                    if (!flgExist)
                    {
                        dwLocal["ROWNID"] = GetSeq();
                        InsertICC_ABAUFM(dwLocal, 1);
                    }
                    UpdateICC_ABAUFM(dwLocal, 1);
                    break;
                case "YCA":
                default:
                    Result = QueryICC_ABAUFM(dwData);
                    if (Result.Tables.Count > 0)
                    {
                        tbLocal = Result.Tables[0];
                        if (tbLocal.Rows.Count > 0)
                        {
                            flgExist = true;
                            dwLocal = tbLocal.Rows[0];
                        }
                        else
                        {
                            dwLocal = tbLocal.NewRow();
                        }
                    }

                    MapICC_ABAUFM(ref dwLocal, dwData);

                    if (!flgExist)
                    {
                        dwLocal["ROWNID"] = GetSeq();
                        InsertICC_ABAUFM(dwLocal, 1);
                    }
                    UpdateICC_ABAUFM(dwLocal, 1);
                    break;


            }

        }
        public DataSet QueryICC_ABAUFM(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            string FSARTPRGR = "";
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT A.*,  LSSTRASSE1,LSAPNA1,LSNAME1,LSAPTEL1"
                    + " FROM (SELECT EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,SUM(ABAQTYRESERVE) AS ABAQTYRESERVE,ABPLIEFNR,MU.ABPART AS ABPART,MAX(MU.FSABEZ) AS FSABEZ"
                        + ",ABPAUFKRS,ABPAUFLFD FROM EKPOS"
                        + " JOIN ICC_ABAUFM MU  ON EKPAUFKRS=ABAAUFKRS AND EKPAUFLFD=ABAAUFLFD AND EKPAUFPOS=ABAAUFPOS"
                        + " JOIN ABPOS P ON MU.ABAVKAUFKRS=P.ABPAUFKRS AND MU.ABAVKAUFLFD=P.ABPAUFLFD  AND MU.ABAVKAUFPOS=P.ABPAUFPOS"
                        + " WHERE EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD AND EKPSA='PO' "
                        + " GROUP BY  EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,ABPAUFKRS,ABPAUFLFD,MU.ABPART,ABPLIEFNR) A"
                    + "  JOIN LIEFDAT S ON A.ABPLIEFNR=S.LSLIEFNR";
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "  SELECT ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,SUM(ABAQTYRESERVE) AS ABAQTYRESERVE"
                        + ",SUM(ABARESMG)AS ABARESMG, SUM(ABAQTYALLOCATE) AS ABAQTYALLOCATE,SUM(ABAQTYRECEIVED) AS ABAQTYRECEIVED,MAX(WAFGRLFD) AS WAFGRLFD,MAX(WAUEBM) AS WAUEBM"
                        + " FROM INTEX.ICC_ABAUFM M WHERE ABAMANDANT=:ABAMANDANT AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE"
                        + " AND ABAGROE=:ABAGROE "
                        + " GROUP BY ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 7:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    break;
                case 8:
                    or1.CommandText = "SELECT M.* FROM INTEX.MDECK R"
                        + " JOIN ICC_ABAUFM M  ON R.MDAUFKRS=M.ABAVKAUFKRS AND R.MDAUFLFD=M.ABAVKAUFLFD AND R.MDAUFPOS=M.ABAVKAUFPOS AND TRIM(R.MDRPOS)=TRIM(M.ABAVKUPOS)"
                        + " WHERE MDMANDANT=:MDMANDANT  AND MDTYP=:MDTYP AND MDMAT=:MDMAT AND MDVAR=:MDVAR";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDTYP", OracleType.NVarChar).Value = dwData["MDTYP"].ToString();
                    or1.Parameters.Add("MDMAT", OracleType.NVarChar).Value = dwData["MDMAT"].ToString();
                    or1.Parameters.Add("MDVAR", OracleType.NVarChar).Value = dwData["MDVAR"].ToString();
                    break;
                case 9:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + " AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break; 
                case 10:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + " AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 101:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + "  AND FSSZUSCHN=:FSSZUSCHN  AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    break;
                case 11:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    break;
                case 12:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<=:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 13:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<=:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 14:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD>:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 15:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABPART=P.ABPART AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD>'" + Left(dwData["ABAVKAUFPOS"].ToString(), 2) + "'"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND SUBSTR(FSSZUSCHN||' ',1,1)=:FSSZUSCHN AND   ABAAUFTYP='N' AND M.ABPART=:ABPART AND M.ABAART=:ABAART"
                        + " AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " AND ABAVKAUFKRS LIKE '%" + dwData["ABAVKAUFKRS"].ToString() + "%' AND ABAVKAUFLFD LIKE '%" + dwData["ABAVKAUFLFD"].ToString() + "%' "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    //or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    //or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    break;
                case 151:
                    string ABPART = dwData["ABPART"].ToString();
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABPART=P.ABPART AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<=:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND FSSZUSCHN=:FSSZUSCHN AND   ABAAUFTYP='N' AND M.ABPART in (" + ABPART + ") AND M.ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    //or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 16:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS"
                    + " AND   ABAART=:ABAART and ABAVAR=:ABAVAR  and ABAFARBE=:ABAFARBE and ABAGROE=:ABAGROE ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 17:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABPART=P.ABPART AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<='" + Left(dwData["ABAVKAUFPOS"].ToString(), 2) + "'"
                        + " WHERE ABAAUFTYP='N' AND SUBSTR(FSSZUSCHN||' ',1,1)=:FSSZUSCHN AND ABAMANDANT=:ABAMANDANT  AND"
                        + "  ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE"
                        + " AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF  AND M.ABPART=:ABPART"
                        + " AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    break;
                case 18:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 19:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD>:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " AND ABAVKAUFKRS=:ABAVKAUFKRS AND  ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    break;
                case 20:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND  ABPERLKZ=' ' "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE "
                        + " AND M.ABPART=:ABPART "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 21:
                    or1.CommandText = "SELECT DISTINCT ABPART,ABAART,FSSZUSCHN FROM ICC_ABAUFM M "
                            + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 23:
                    or1.CommandText = "SELECT M.* FROM FDECK M "
                        + " JOIN ABPOS P ON M.FDAUFKRS=P.ABPAUFKRS AND M.FDAUFLFD=P.ABPAUFLFD AND M.FDAUFPOS=P.ABPAUFPOS "
                        + " WHERE FDMANDANT=:FDMANDANT  AND FDART=:FDART AND FDVAR=:FDVAR AND FDFARBE=:FDFARBE AND FDGROE=:FDGROE "
                        + " AND ABPART=:ABPART "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDART", OracleType.NVarChar).Value = dwData["FDART"].ToString();
                    or1.Parameters.Add("FDVAR", OracleType.NVarChar).Value = dwData["FDVAR"].ToString();
                    or1.Parameters.Add("FDFARBE", OracleType.NVarChar).Value = dwData["FDFARBE"].ToString();
                    or1.Parameters.Add("FDGROE", OracleType.NVarChar).Value = dwData["FDGROE"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 24:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD "
                    + " AND   ABAART=:ABAART  ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    break;
                case 25:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    break;
                case 26:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABPART=:ABPART "
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 27:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS  ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    break;
                case 28:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAAUFTYP='V' AND ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    break;
                case 30:
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABPMANDANT  AND ABAVKAUFKRS=:ABPAUFKRS AND ABAVKAUFLFD=:ABPAUFLFD AND ABPART=:ABPART AND ABPFARBE=:ABPFARBE";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABPFARBE", OracleType.NVarChar).Value = dwData["ABPFARBE"].ToString();
                    break;
                case 99:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD  ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    break;
                case 911://分组 
                    or1.CommandText = "SELECT DISTINCT A.*,Trim(C.FSFFBEZ) AS CDES,NVL(SP.LSLIEFNA,'YCA       ') AS SELLER, NVL(SP.LSNAME1,'YCA                                     ') AS SELLERNAME "
                    + " FROM (SELECT DISTINCT FDMANDANT AS MANDANT,FDTYP AS DTYP,FDART AS ART,FDVAR AS VAR,FDFARBE AS COLOR ,"
                    + " Trim(MAX(S.FSABEZ))AS ARTDES, FDGROE AS ASIZE,ABACOLORREF AS CREF,M.ABPART,MAX(M.FSABEZ) AS FSABEZ,"
                    + " SUM(ABARESMG) AS REQ,NVL(MAX(S.FSUEBM),'PCS') AS UM,ABPSPGRD,ABAVKAUFKRS,ABAVKAUFLFD ,'0' AS PLANRATE,'0' AS WASTAGEEK "
                    + " FROM INTEX.FDECK R "
                    + " JOIN INTEX.ICC_ABAUFM M ON R.FDAUFKRS=M.ABAVKAUFKRS AND R.FDAUFLFD=M.ABAVKAUFLFD AND R.FDAUFPOS=M.ABAVKAUFPOS AND ABAART=FDART AND  "
                    + " ABAVAR =FDVAR AND  ABAFARBE= FDFARBE  AND ABAGROE=FDGROE JOIN ABPOS P ON  "
                    + " P.ABPAUFKRS=R.FDAUFKRS AND P.ABPAUFLFD=R.FDAUFLFD AND P.ABPAUFPOS=R.FDAUFPOS LEFT JOIN FSSTAMM S"
                    + " ON R.FDART=S.FSART AND R.FDVAR=S.FSVAR  "
                    + " WHERE  ABAART LIKE '%" + dwData["FDART"].ToString().Trim()
                    + "%' AND M.ABPART LIKE '%" + dwData["FDFILLER"].ToString().Trim()
                    + "%' AND ABAVKAUFKRS LIKE '%" + dwData["FDAUFKRS"].ToString().Trim()
                    + "%' AND ABAVKAUFLFD LIKE '%" + dwData["FDAUFLFD"].ToString().Trim()
                    + "%' AND FDMANDANT=:FDMANDANT  AND FDTYP=:FDTYP AND FDSA=:FDSA AND FDZUGET=0 AND FDRESERV=0 AND M.ABAAUFTYP='N'"
                        //''+" AND FDART LIKE 'B140100115%' "
                    + " GROUP BY FDMANDANT,FDTYP,FDART,FDVAR,FDFARBE,FDGROE,ABACOLORREF,M.ABPART,ABPSPGRD,ABAVKAUFKRS,ABAVKAUFLFD"
                    + " ORDER BY FDMANDANT,FDTYP,FDART,FDVAR,FDFARBE,FDGROE,ABACOLORREF,ABPSPGRD,ABAVKAUFKRS,ABAVKAUFLFD"
                    + " ) A   LEFT JOIN FSFARBEN C ON A.ART=FSFART AND A.VAR=FSFVAR AND A.COLOR=C.FSFFARBE"
                    + " LEFT JOIN FSEINK K ON A.ART=K.FEART AND A.VAR=K.FEVAR "
                    + " LEFT JOIN LIEFDAT SP ON FELIEFNR=SP.LSLIEFNR";

                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDTYP", OracleType.NVarChar).Value = dwData["FDTYP"].ToString();
                    or1.Parameters.Add("FDSA", OracleType.NVarChar).Value = dwData["FDSA"].ToString();
                    break;
                case 91:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = "SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + " AND FSSZUSCHN=:FSSZUSCHN AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    break;
                case 921://分组 
                    or1.CommandText = "SELECT ABPSPGRD,ABAVKAUFKRS,ABAVKAUFLFD,WDMANDANT AS MANDANT,WDTYP AS DTYP,WDART AS ART,WDVAR AS VAR,WDFARBE AS COLOR,"
                        + " MAX(Trim(WAFBEZ)) AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MAX(S.WAUEBM) AS UM,MAX(Trim(S.WABEZ))AS ARTDES,"
                        + "SUM(ABARESMG) AS REQ,MAX(S.WAFGRLFD) AS FGRLFD,SUM(ABARESMG) AS MTRREQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME,FSSZUSCHN,M.ABPART,MAX(EXART) AS EXART,MAX(EXCOLOR) AS EXCOLOR,'0' AS PLANRATE,'0' AS WASTAGEEK "
                        + " FROM INTEX.WDECK R JOIN INTEX.ICC_ABAUFM M ON R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS"
                        + " AND R.WDUPOS=M.ABAVKUPOS AND ABAART=WDART AND WDVAR=ABAVAR AND ABAFARBE=WDFARBE"
                        + " LEFT JOIN WASTAMM S ON R.WDART=S.WAART AND R.WDVAR=S.WAVAR"
                        + " LEFT JOIN WAFARBEN F ON R.WDART=WAFART AND R.WDVAR=WAFVAR AND WDFARBE=WAFZUSATZ "
                        + " LEFT JOIN LIEFDAT SP ON WALIEFNR=SP.LSLIEFNR"
                        + " JOIN ABPOS P ON WDAUFKRS=ABPAUFKRS  AND WDAUFLFD=ABPAUFLFD    AND WDAUFPOS=ABPAUFPOS"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP "
                                     + " AND ABAVKAUFKRS LIKE '%" + dwData["WDAUFKRS"].ToString().Trim() + "%'"
                         + " AND ABAVKAUFLFD LIKE '%" + dwData["WDAUFLFD"].ToString().Trim() + "%'"
                        + " AND WDZUGET=0 AND WDRESERV=0 AND M.ABAAUFTYP='N' AND M.FSSZUSCHN=:FSSZUSCHN "
                        + " GROUP BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,ABACOLORREF,FSSZUSCHN,M.ABPART,ABPSPGRD,ABAVKAUFKRS,ABAVKAUFLFD"
                        + " ORDER BY ABPART,FSSZUSCHN,WDART,WDVAR,WDFARBE,ABACOLORREF,ABPSPGRD,ABAVKAUFKRS,ABAVKAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;

                case 31:
                    or1.CommandText = "SELECT M.ABPART,KRS,LFD,MAX(TQTYD) AS TQTYD,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,ABAART,ABAFARBE,M.RATIO,M.UM,MAX(PQTY) AS PQTY,SUM(ABARESMG) AS REQ,SUM(ABARESMG) AS REQADD,0 AS EKADD,0 AS EKW,SUM(ABAQTYRESERVE) AS ABAQTYRESERVE,MAX(EKPME1*0.01) AS EKPME1,MAX(EKPEFARBE) AS EKPEFARBE ,MAX(EKPEART) AS EKPEART,MAX(FBRTU) AS FBRTU,MAX(FBRTL) AS FBRTL,MAX(LSSTRASSE1) AS LSSTRASSE1,MAX(LSAPNA1) AS LSAPNA1,MAX(LSNAME1) AS LSNAME1,MAX(LSAPTEL1) AS LSAPTEL1,MAX(NVL(S.WAFGRLFD,1)) AS FGRLFD "
                    + " FROM ICC_ABAUFM M JOIN EKPOS ON EKPSA='PO' AND EKPAUFKRS=ABAAUFKRS AND ABAAUFLFD=EKPAUFLFD AND ABAAUFPOS=EKPAUFPOS JOIN ICC_ABPOS_MAT T ON KRS=ABAVKAUFKRS AND LFD=ABAVKAUFLFD AND T.ABPART=M.ABPART AND T.ABPFARBE=M.ABPFARBE"
                    + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD  AND M.ABAVKAUFPOS=P.ABPAUFPOS"
                    + "  JOIN LIEFDAT S ON P.ABPLIEFNR=S.LSLIEFNR"
                    + " LEFT JOIN WASTAMM S ON M.ABAART=S.WAART "
                   + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD   "
                    +" GROUP BY  M.ABPART,M.ABPFARBE,KRS,LFD,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,ABAART,ABAFARBE,M.RATIO,M.UM";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break; 
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_ABAUFM";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public void UpdateICC_ABAUFM(DataRow dwData, int option, string ITXDBVERSION = "50.24")
        {
             
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "UPDATE ICC_ABAUFM SET "
                        + "ABAAUFTYP=:ABAAUFTYP,"
                        + "ABAAUFKRS=:ABAAUFKRS,"
                        + "ABAAUFLFD=:ABAAUFLFD,"
                        + "ABAAUFPOS=:ABAAUFPOS,"
                        + "ABARESMG=:ABARESMG,"
                        + "ABAQTYRESERVE=:ABAQTYRESERVE,"
                        + "ABAQTYALLOCATE=:ABAQTYALLOCATE,"
                        + "ABAQTYRECEIVED=:ABAQTYRECEIVED"
                        + " WHERE  "
                        + "  ABAID=:ABAID ";
                    or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwData["ABAAUFTYP"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    or1.Parameters.Add("ABARESMG", OracleType.NVarChar).Value = dwData["ABARESMG"].ToString();
                    or1.Parameters.Add("ABAQTYRESERVE", OracleType.NVarChar).Value = dwData["ABAQTYRESERVE"].ToString();
                    or1.Parameters.Add("ABAQTYALLOCATE", OracleType.NVarChar).Value = dwData["ABAQTYALLOCATE"].ToString();
                    or1.Parameters.Add("ABAQTYRECEIVED", OracleType.NVarChar).Value = dwData["ABAQTYRECEIVED"].ToString();
                    or1.Parameters.Add("ABAID", OracleType.NVarChar).Value = dwData["ABAID"].ToString().Trim();
                    break;
                case 2:
                    or1.CommandText = "UPDATE WASTAMM M SET WABIND='0              ' WHERE TRIM(WABIND) IS NULL";
                    break;
                case 3:
                    or1.CommandText = "UPDATE ICC_ABAUFM SET "
                            + "CONTROL=:CONTROL,"
                        + "ABAAUFTYP=:ABAAUFTYP,"
                        + "ABAAUFKRS=:ABAAUFKRS,"
                        + "ABAAUFLFD=:ABAAUFLFD,"
                        + "ABAAUFPOS=:ABAAUFPOS,"
                        + "ABARESMG=:ABARESMG,"
                        + "QTYPLAN=:ABARESMG,"
                        + "RATIO=:RATIO,"
                        + "ABAQTYRESERVE=:ABAQTYRESERVE,"
                        + "ABAQTYALLOCATE=:ABAQTYALLOCATE,"
                        + "ABAQTYRECEIVED=:ABAQTYRECEIVED"                        
                        + " WHERE  "
                        + "  ABAID=:ABAID ";
                    or1.Parameters.Add("CONTROL", OracleType.NVarChar).Value = dwData["CONTROL"].ToString();
                    or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwData["ABAAUFTYP"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    or1.Parameters.Add("RATIO", OracleType.NVarChar).Value = dwData["RATIO"].ToString(); 
                    or1.Parameters.Add("ABARESMG", OracleType.NVarChar).Value = dwData["ABARESMG"].ToString();
                    or1.Parameters.Add("ABAQTYRESERVE", OracleType.NVarChar).Value = dwData["ABAQTYRESERVE"].ToString();
                    or1.Parameters.Add("ABAQTYALLOCATE", OracleType.NVarChar).Value = dwData["ABAQTYALLOCATE"].ToString();
                    or1.Parameters.Add("ABAQTYRECEIVED", OracleType.NVarChar).Value = dwData["ABAQTYRECEIVED"].ToString();
                    or1.Parameters.Add("ABAID", OracleType.NVarChar).Value = dwData["ABAID"].ToString().Trim();
                    break;
                case 5:
                    or1.CommandText = "UPDATE ICC_ABAUFM SET "
                        + "ABAAUFTYP=:ABAAUFTYP "
                        + " WHERE  "
                        + "  ABAID=:ABAID ";
                    or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwData["ABAAUFTYP"].ToString();
                    or1.Parameters.Add("ABAID", OracleType.NVarChar).Value = dwData["ABAID"].ToString().Trim();
                    break;
                case 10:
                    or1.CommandText = "UPDATE ICC_ABAUFM SET "
                        + "ABAAUFTYP=:ABAAUFTYP,"
                        + "ABAAUFKRS=:ABAAUFKRS,"
                        + "ABAAUFLFD=:ABAAUFLFD,"
                        + "ABAAUFPOS=:ABAAUFPOS,"
                        + "ABAQTYRESERVE=:ABAQTYRESERVE,"
                        + "ABAQTYALLOCATE=:ABAQTYALLOCATE,"
                        + "ABAQTYRECEIVED=:ABAQTYRECEIVED"
                        + " WHERE  "
                        + "  ABAID=:ABAID ";
                    or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwData["ABAAUFTYP"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    or1.Parameters.Add("ABAQTYRESERVE", OracleType.NVarChar).Value = dwData["ABAQTYRESERVE"].ToString();
                    or1.Parameters.Add("ABAQTYALLOCATE", OracleType.NVarChar).Value = dwData["ABAQTYALLOCATE"].ToString();
                    or1.Parameters.Add("ABAQTYRECEIVED", OracleType.NVarChar).Value = dwData["ABAQTYRECEIVED"].ToString();
                    or1.Parameters.Add("ABAID", OracleType.NVarChar).Value = dwData["ABAID"].ToString().Trim();
                    break;
                case 11:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.ARTDES,FSKOLL)=(SELECT FSABEZ,FSKOLL FROM FSSTAMM W WHERE ABAART=W.FSART)"
                        + " WHERE    EXISTS (SELECT 1 FROM FSSTAMM W WHERE ABAART=W.FSART)";
                    break;
                case 12:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.CDES)=(SELECT FSFABEZ FROM FSFARBEN W WHERE ABAART=W.FSFART AND ABAFARBE=FSFFARBE)"
                        + " WHERE    EXISTS (SELECT FSFABEZ FROM FSFARBEN W WHERE ABAART=W.FSFART AND ABAFARBE=FSFFARBE)";
                    break;
                case 13:
                    or1.CommandText = "UPDATE ICC_ABAUFM SET "
                        + "ABARESMG=:ABARESMG"
                        + " WHERE  "
                        + "  ABAID=:ABAID ";
                    or1.Parameters.Add("ABARESMG", OracleType.NVarChar).Value = dwData["ABARESMG"].ToString();
                    or1.Parameters.Add("ABAID", OracleType.NVarChar).Value = dwData["ABAID"].ToString().Trim();
                    break;

                case 20:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.WAFGRLFD,FBRTU,FBRTL,ARTDES,EXART,EXCOLOR)="
                        + "(SELECT W.WAFGRLFD,WAFBRTU,WAFBRTL,WABEZ,WALOHNA,WAFMUDESS FROM WASTAMM W,WAFARBEN F "
                        + "  WHERE ABAART=W.WAART  AND WAFART=ABAART AND WAFZUSATZ=ABAFARBE)"
                        + " WHERE   CONTROL<>'FN '  AND  EXISTS ( SELECT 1 FROM WASTAMM W,WAFARBEN WHERE ABAART=W.WAART AND WAFART=ABAART AND WAFZUSATZ=ABAFARBE)";
                    break;
                case 201:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)="
                        + "(SELECT TO_NUMBER(W.WABIND) FROM WASTAMM W "
                        + "  WHERE ABAART=W.WAART )"
                        + " WHERE   CONTROL<>'FN '  AND  EXISTS  (SELECT 1 FROM WASTAMM W WHERE ABAART=W.WAART )";
                    break;
                /*UPDATE ICC_ABAUFM M SET (EXART,EXCOLOR)=(SELECT WALOHNA,WAFMUDESS FROM
WASTAMM,WAFARBEN WHERE WAART=ABAART AND WAFART=ABAART AND WAFZUSATZ=ABAFARBE)
WHERE EXISTS
(SELECT 1 FROM
WASTAMM,WAFARBEN WHERE WAART=ABAART AND WAFART=ABAART AND WAFZUSATZ=ABAFARBE)*/
                case 21:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET  (FSSZUSCHN,UM,RATIO)=(SELECT DISTINCT MAX(FSSZUSCHN), MAX(FSSVBME) AS UM, MAX(FSSVERBR*FSSVBFKT * 0.000001 * (1 + FSSVERL * 0.0001)*0.001) FROM FSSTUELI B WHERE TO_NUMBER(ABAVKUPOS)=TO_NUMBER(FSSPOS)/10 AND FSSMATKZ='F' AND  B.FSSART=M.ABPART AND (B.FSSFARBE=M.ABPFARBE OR FSSFARBE='          ') AND B.FSSMART=M.ABAART AND (B.FSSMFARBE = M.ABAFARBE )  GROUP BY FSSART,FSSMART,FSSMFARBE,FSSFARBE)  WHERE EXISTS (SELECT 1 FROM FSSTUELI B WHERE TO_NUMBER(ABAVKUPOS)=TO_NUMBER(FSSPOS)/10 AND FSSMATKZ='F' AND  B.FSSART=M.ABPART AND (B.FSSFARBE=M.ABPFARBE OR FSSFARBE='          ')  AND B.FSSMART=M.ABAART AND (B.FSSMFARBE = M.ABAFARBE ))   AND M.ABAAUFTYP='N' AND MTYPE='F'";
                    break;
                #region======Cost=======
                case 22:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)=(SELECT TO_NUMBER('0'||TRIM(W.WABIND))  FROM WASTAMM W WHERE ABAART=W.WAART)"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE  CONTROL<>'FN ' AND  ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + " EXISTS(SELECT 1 FROM WASTAMM W WHERE ABAART=W.WAART )";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 221:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)=(SELECT TO_NUMBER('0'||TRIM(W.WABIND))  FROM WASTAMM W WHERE ABAART=W.WAART)"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE   ABAAUFTYP='N' AND"
                        + " EXISTS(SELECT 1 FROM WASTAMM W WHERE ABAART=W.WAART )";
                    break;
                case 27:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)=(SELECT TO_NUMBER(TRIM('0'||W.WAFZUABAK))/100 FROM WAFARBEN W WHERE ABAART=W.WAFART  AND ABAFARBE=W.WAFZUSATZ AND WAFZUABAK>0)"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE   CONTROL<>'FN ' AND  ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS(SELECT 1 FROM WAFARBEN W WHERE ABAART=W.WAFART AND ABAFARBE=W.WAFZUSATZ AND WAFZUABAK>0)";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 28:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (CDES)=(SELECT  WAFBEZ FROM WAFARBEN W WHERE ABAART=W.WAFART  AND ABAFARBE=W.WAFZUSATZ)"
                        + " WHERE  CONTROL<>'FN ' AND  ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS(SELECT 1 FROM WAFARBEN W WHERE ABAART=W.WAFART AND ABAFARBE=W.WAFZUSATZ  )";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    break;
                case 23:
                    or1.CommandText = "   UPDATE ICC_ABAUFM M SET PREK=("
                        //+ " SELECT CASE EKPMEEH WHEN 'KG ' THEN EKPPRME*0.001*wafgrlfd *0.001 ELSE EKPPRME*0.001 END AS PREK FROM EKPOS EK"
                        + " SELECT  EKPPRME*0.001 AS PREK FROM EKPOS EK"
                        + " WHERE M.ABAAUFKRS=EKPAUFKRS AND M.ABAAUFLFD=EKPAUFLFD AND M.ABAAUFPOS=EKPAUFPOS AND EKPSA='PO')"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE  CONTROL<>'FN ' AND   ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS (SELECT 1 FROM EKPOS EK WHERE M.ABAAUFKRS=EKPAUFKRS AND M.ABAAUFLFD=EKPAUFLFD AND M.ABAAUFPOS=EKPAUFPOS AND EKPSA='PO')";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 24:
                    or1.CommandText = "   UPDATE ICC_ABAUFM M SET (M.PRSTD)="
                        + " (SELECT MAX(FEPREIS1*0.01/FEMINBSLM1) FROM FSEINK W WHERE ABAART=W.FEART AND FEFARBE='          ' AND FEGROE='       ' )"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE   CONTROL<>'FN ' AND ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS(SELECT 1  FROM FSEINK W WHERE ABAART=W.FEART AND FEFARBE='          ' AND FEGROE='       ');";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 241:
                    or1.CommandText = "   UPDATE ICC_ABAUFM M SET (M.PRSTD)="
                        + " (SELECT MAX(FEPREIS1*0.01/FEMINBSLM1) FROM FSEINK W WHERE ABAART=W.FEART AND FEFARBE='          ' AND FEGROE='       ' )"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE     ABAAUFTYP='N' AND"
                        + "  EXISTS(SELECT 1  FROM FSEINK W WHERE ABAART=W.FEART AND FEFARBE='          ' AND FEGROE='       ');";

                    break;
                case 25:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)="
                                    + " (SELECT FEPREIS1*0.01/FEMINBSLM1 FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND FEGROE='       ')"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE CONTROL<>'FN ' AND  ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                                    + "   EXISTS(SELECT 1  FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND FEGROE='       ');";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 251:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)="
                        + " (SELECT FEPREIS1*0.01/FEMINBSLM1 FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND FEGROE='       ')"
                        + " WHERE   ABAAUFTYP='N' AND"
                                    + "   EXISTS(SELECT 1  FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND FEGROE='       ');";
                    break;
                case 26:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)="
                        + "(SELECT FEPREIS1*0.01/FEMINBSLM1 FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND ABAGROE=FEGROE)"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE  CONTROL<>'FN ' AND  ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "   EXISTS(SELECT 1  FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND ABAGROE=FEGROE);";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 261:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET (M.PRSTD)="
                        + "(SELECT FEPREIS1*0.01/FEMINBSLM1 FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND ABAGROE=FEGROE)"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE   CONTROL<>'FN '  AND ABAAUFTYP='N' AND"
                        + "   EXISTS(SELECT 1  FROM FSEINK W WHERE ABAART=W.FEART AND ABAFARBE=FEFARBE AND ABAGROE=FEGROE);";
                    break;
                case 41:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET QTYACT=(SELECT SUM(FBWME) AS FBWME FROM FBEW W"
                        + " WHERE FBWMANDANT=M.ABAMANDANT AND FBWAUFTYP='V' AND M.ABAVKAUFKRS=FBWAUFKRS"
                        + " AND ABAVKAUFLFD=FBWAUFLFD AND ABAVKAUFPOS=FBWAUFPOS AND FBWART=ABAART  AND FBWFARBE=ABAFARBE"
                        + " AND ABAGROE=FBWGROE AND FBWFC='AV25    ' AND FBWBS=36) "
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE  CONTROL<>'FN ' AND  ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS (SELECT 1  FROM FBEW W"
                        + " WHERE FBWMANDANT=M.ABAMANDANT AND FBWAUFTYP='V' AND M.ABAVKAUFKRS=FBWAUFKRS"
                        + " AND ABAVKAUFLFD=FBWAUFLFD AND ABAVKAUFPOS=FBWAUFPOS AND FBWART=ABAART AND FBWFARBE=ABAFARBE"
                        + " AND ABAGROE=FBWGROE AND FBWFC='AV25    ' AND FBWBS=36)";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 42:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET QTYACT=(SELECT SUM(WBEWMTR)*0.001 FROM WBBEW W"
                        + " WHERE WBEWMANDANT=M.ABAMANDANT AND WBEWAUFTYP='V' AND M.ABAVKAUFKRS=WBEWAUFKRS"
                        + " AND ABAVKAUFLFD=WBEWAUFLFD AND ABAVKAUFPOS=WBEWAUFPOS AND WBEWART=ABAART "
                        + " AND  WBEWFARBE=ABAFARBE AND WBEWBS=36)"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE  CONTROL<>'FN ' AND  ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS (SELECT 1 FROM WBBEW W WHERE WBEWMANDANT=M.ABAMANDANT AND WBEWAUFTYP='V' AND M.ABAVKAUFKRS=WBEWAUFKRS"
                        + " AND ABAVKAUFLFD=WBEWAUFLFD AND ABAVKAUFPOS=WBEWAUFPOS AND WBEWART=ABAART "
                        //+" AND WBEWVAR=ABAVAR"
                        + " AND  WBEWFARBE=ABAFARBE AND WBEWBS=36)";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 51:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET QTYPLAN=ABAQTYRESERVE,QTYSTD=(SELECT P.S*RATIO FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='S      ')"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE CONTROL<>'FN ' AND   ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS  (SELECT 1 FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='S      ')";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 52:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET QTYPLAN=ABAQTYRESERVE,QTYSTD=(SELECT P.S*RATIO FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='M      ')"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE CONTROL<>'FN ' AND   ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS  (SELECT 1 FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='M      ')";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 53:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET QTYPLAN=ABAQTYRESERVE,QTYSTD=(SELECT P.S*RATIO FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='L      ')"
                        //+ " WHERE ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND ABPVAR=:VAR AND ABPFARBE=:FARBE AND "
                        + " WHERE  CONTROL<>'FN ' AND   ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS  (SELECT 1 FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='L      ')";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 54:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET QTYPLAN=ABAQTYRESERVE,QTYSTD=(SELECT P.S*RATIO FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='XL     ')"
                        + " WHERE  CONTROL<>'FN ' AND   ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART AND "
                        + "  EXISTS  (SELECT 1 FROM ICC_ABPOS_MCO P WHERE P.KRS=ABAVKAUFKRS AND P.LFD=ABAVKAUFLFD AND P.FARBE=M.ABPFARBE"
                        + " AND P.ART=M.ABPART AND P.VAR=M.ABPVAR AND P.FARBE=M.ABPFARBE AND M.ABPGROE='XL     ')";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                case 55:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET CONTROL='   '  WHERE   ABAMANDANT=:MANDANT AND ABAVKAUFKRS=:KRS AND ABAVKAUFLFD=:LFD AND ABPART=:ART   " ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"];
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"];
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"];
                    or1.Parameters.Add("ART", OracleType.NVarChar).Value = dwData["ART"];
                    //or1.Parameters.Add("VAR", OracleType.NVarChar).Value = dwData["VAR"];
                    //or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"];
                    break;
                #endregion
                case 99:
                    or1.CommandText = "UPDATE ICC_ABAUFM M SET "
                    + "CONTROL=:CONTROL,"
                    + "QTYACT=:QTYACT," 
                    + "PRSTD=:PRSTD,"
                    + "PREK=:PREK,"
                    + "PRPLAN=:PRPLAN," 
                    + "VQTYSTDPRSTD=:VQTYSTDPRSTD,"
                    + "VQTYSTDPREK=:VQTYSTDPREK,"
                    + "VQTYSTDPRPLAN=:VQTYSTDPRPLAN," 
                    + "VQTYPLANPRSTD=:VQTYPLANPRSTD,"
                    + "VQTYPLANPREK=:VQTYPLANPREK,"
                    + "VQTYPLANPRPLAN=:VQTYPLANPRPLAN," 
                    + "VQTYACTPRSTD=:VQTYACTPRSTD,"
                    + "VQTYACTPREK=:VQTYACTPREK,"
                    + "VQTYACTPRPLAN=:VQTYACTPRPLAN"
                        + " WHERE ABAID=:ABAID";

                    or1.Parameters.Add("ABAID", OracleType.NVarChar).Value = dwData["ABAID"].ToString().Trim();
                    or1.Parameters.Add("CONTROL", OracleType.NVarChar).Value = dwData["CONTROL"].ToString();
                    or1.Parameters.Add("QTYACT", OracleType.NVarChar).Value = dwData["QTYACT"].ToString();

                    or1.Parameters.Add("PRSTD", OracleType.NVarChar).Value = dwData["PRSTD"].ToString();
                    or1.Parameters.Add("PREK", OracleType.NVarChar).Value = dwData["PREK"].ToString();
                    or1.Parameters.Add("PRPLAN", OracleType.NVarChar).Value = dwData["PRPLAN"].ToString();

                    or1.Parameters.Add("VQTYSTDPRSTD", OracleType.NVarChar).Value = dwData["VQTYSTDPRSTD"].ToString();
                    or1.Parameters.Add("VQTYSTDPREK", OracleType.NVarChar).Value = dwData["VQTYSTDPREK"].ToString();
                    or1.Parameters.Add("VQTYSTDPRPLAN", OracleType.NVarChar).Value = dwData["VQTYSTDPRPLAN"].ToString();

                    or1.Parameters.Add("VQTYPLANPRSTD", OracleType.NVarChar).Value = dwData["VQTYPLANPRSTD"].ToString();
                    or1.Parameters.Add("VQTYPLANPREK", OracleType.NVarChar).Value = dwData["VQTYPLANPREK"].ToString();
                    or1.Parameters.Add("VQTYPLANPRPLAN", OracleType.NVarChar).Value = dwData["VQTYPLANPRPLAN"].ToString();

                    or1.Parameters.Add("VQTYACTPRSTD", OracleType.NVarChar).Value = dwData["VQTYACTPRSTD"].ToString();
                    or1.Parameters.Add("VQTYACTPREK", OracleType.NVarChar).Value = dwData["VQTYACTPREK"].ToString();
                    or1.Parameters.Add("VQTYACTPRPLAN", OracleType.NVarChar).Value = dwData["VQTYACTPRPLAN"].ToString();

                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }

        public void UpdateICC_ABAUFM(string ptype, string client, string krs, string lfd, string pos)
        {
             or1 = OracleDB.CreateCommand();
            switch (ptype)
            {
                case "EK":
                    or1.CommandText = "UPDATE ICC_ABAUFM SET "
                        + "ABAAUFTYP='N',"
                        + "ABAAUFKRS='  ',"
                        + "ABAAUFLFD='      ',"
                        + "ABAAUFPOS='   ',"
                        + "ABAQTYRESERVE=0,"
                        + "ABAQTYALLOCATE=0,"
                        + "ABAQTYRECEIVED=0"
                        + " WHERE  ABAAUFTYP=:ABAAUFTYP AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS";
                    or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = "P";
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = lfd;
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = pos;
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }

        public void DeleteICC_ABAUFM(string client, string krs, string lfd, string pos, DataRow dwData = null, int option = 1)
        {
             or1 = OracleDB.CreateCommand();

            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM ICC_ABAUFM WHERE  "
          + "  ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = lfd;
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = pos;
                    break;
                case 2:
                    or1.CommandText = "DELETE FROM ICC_ABAUFM WHERE  "
          + "  ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = lfd;

                    break;
                case 3:
                    or1.CommandText = "DELETE FROM  ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND .ABAVKAUFPOS=:ABAVKAUFPOS AND  TRIM(ABAVKUPOS)=:ABAVKUPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    or1.Parameters.Add("ABAVKUPOS", OracleType.NVarChar).Value = dwData["ABAVKUPOS"].ToString().Trim();
                    break;
                case 4:
                    or1.CommandText = "DELETE FROM ICC_ABAUFM  "
                    + " WHERE ABAID=:ABAID";
                    or1.Parameters.Add("ABAID", OracleType.NVarChar).Value = dwData["ABAID"].ToString();
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
        public void InsertICC_ABAUFM(DataRow dwData, int option, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "INSERT INTO ICC_ABAUFM(ABAID,ABAMANDANT,MTYPE,ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,ABAERLKZ,QTYPLAN,ABARESMG, ABAQTYALLOCATE,ABAQTYRESERVE,ABAQTYRECEIVED,ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS"
                + ", ABAVKUPOS,ABAART,ABAVAR,ABAFARBE,ABAGROE,ABACOLORREF,ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,WAUEBM,WAFGRLFD,FSARTPRGR,FSKOLL)"
                    + " SELECT SEQ_ICC_MU.NEXTVAL,R.MDMANDANT,'M','N','  ','      ','   ','N',R.MDMENGE*0.001,R.MDMENGE*0.001,0,0,0,R.MDTYP,R.MDAUFKRS,R.MDAUFLFD,R.MDAUFPOS,R.MDRPOS,substr(mdmat||'                ',1,20),R.MDVAR,substr( '                    ',1,10),substr( '                    ',1,7),MDFILLER, "
                    + "ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,'','',FSARTPRGR,FSKOLL FROM MDECK R"
                    + " JOIN ABPOS ON ABPAUFKRS=MDAUFKRS AND ABPAUFLFD=MDAUFLFD AND ABPAUFPOS=MDAUFPOS"
                    + " LEFT JOIN FSSTAMM ON ABPART=FSART "
                    + " LEFT JOIN FSFARBEN ON FSFART=ABPART  AND FSFFARBE=ABPFARBE "
                    + " LEFT JOIN LIEFDAT ON ABPLIEFNR=LSLIEFNR"
                    + " WHERE NOT EXISTS "
                    + " (SELECT 1 FROM ICC_ABAUFM M  WHERE R.MDAUFKRS=M.ABAVKAUFKRS AND R.MDAUFLFD=M.ABAVKAUFLFD AND R.MDAUFPOS=M.ABAVKAUFPOS AND TRIM(R.MDRPOS)=TRIM(M.ABAVKUPOS))";
                    break;
                case 2:
                    or1.CommandText = "INSERT INTO ICC_ABAUFM(ABAID,ABAMANDANT,MTYPE,ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,ABAERLKZ,QTYPLAN,ABARESMG, ABAQTYALLOCATE,ABAQTYRESERVE,ABAQTYRECEIVED,ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS"
                + ", ABAVKUPOS,ABAART,ABAVAR,ABAFARBE,ABAGROE,ABACOLORREF,ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,WAUEBM,WAFGRLFD,FSARTPRGR,EXART,EXCOLOR,FSKOLL)"
                    + " SELECT SEQ_ICC_MU.NEXTVAL,R.WDMANDANT,'F','N','  ','      ','   ','N',R.WDBEDARF*0.01,R.WDBEDARF*0.01,0,0,0,R.WDTYP,R.WDAUFKRS,R.WDAUFLFD,R.WDAUFPOS,R.WDUPOS,WDART,WDVAR,WDFARBE,substr( '                    ',1,7), WDFILLER,"
                    + " ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,WAUEBM,WAFGRLFD,FSARTPRGR,WALOHNA,WAFMUDESS,FSKOLL FROM WDECK R "
                    + " JOIN ABPOS ON ABPAUFKRS=WDAUFKRS AND ABPAUFLFD=WDAUFLFD AND ABPAUFPOS=WDAUFPOS"
                     + " LEFT JOIN FSSTAMM ON ABPART=FSART "
                    + " LEFT JOIN FSFARBEN ON FSFART=ABPART AND FSFFARBE=ABPFARBE "
                    + " LEFT JOIN LIEFDAT ON ABPLIEFNR=LSLIEFNR"
                    + " LEFT JOIN WASTAMM ON WDART=WAART AND WDVAR=WAVAR"
                    + " LEFT JOIN WAFARBEN ON WAFART=WDART AND WAFZUSATZ=WDFARBE"
                    + " WHERE NOT EXISTS "
                    + " (SELECT 1 FROM ICC_ABAUFM M  WHERE R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS AND WDART=ABAART AND WDFARBE=ABAFARBE)";
                    break;
                case 3:
                    or1.CommandText = "INSERT INTO ICC_ABAUFM(ABAID,ABAMANDANT,MTYPE,ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,ABAERLKZ,QTYPLAN,ABARESMG, ABAQTYALLOCATE,ABAQTYRESERVE,ABAQTYRECEIVED,ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS"
               + ", ABAVKUPOS,ABAART,ABAVAR,ABAFARBE,ABAGROE,ABACOLORREF,ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,WAUEBM,WAFGRLFD,FSARTPRGR,FSKOLL)"
                    + " SELECT SEQ_ICC_MU.NEXTVAL,R.FDMANDANT,'T','N','  ','      ','   ','N',R.FDMENGE,R.FDMENGE,0,0,0,R.FDTYP,R.FDAUFKRS,R.FDAUFLFD,R.FDAUFPOS,SUBSTR(R.FDSETPOS,2,2),FDART,FDVAR,FDFARBE,FDGROE, FDFILLER,"
                    + "ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,'',0,FSARTPRGR,FSKOLL  FROM FDECK R "
                        //+ " JOIN ABPOS P ON ABPAUFKRS=FDAUFKRS AND ABPAUFLFD=FDAUFLFD AND ABPAUFPOS=FDAUFPOS AND P.ABPSPGRD<='89'"
                    + " JOIN ABPOS P ON ABPAUFKRS=FDAUFKRS AND ABPAUFLFD=FDAUFLFD AND ABPAUFPOS=FDAUFPOS"
                    + " LEFT JOIN FSSTAMM ON ABPART=FSART "
                    + " LEFT JOIN FSFARBEN ON FSFART=ABPART AND FSFFARBE=ABPFARBE "
                    + " LEFT JOIN LIEFDAT ON ABPLIEFNR=LSLIEFNR"
                   + " WHERE  FDSA='V' AND FDTYP='B' AND NOT EXISTS"
                   + "(SELECT 1 FROM ICC_ABAUFM M WHERE R.FDAUFKRS=M.ABAVKAUFKRS AND R.FDAUFLFD=M.ABAVKAUFLFD AND R.FDAUFPOS=M.ABAVKAUFPOS AND R.FDART=ABAART AND R.FDVAR=ABAVAR AND R.FDFARBE=ABAFARBE AND R.FDGROE=ABAGROE )";
                    break;
                case 4:
                    or1.CommandText = "INSERT INTO ICC_ABAUFM(ABAID,ABAMANDANT,MTYPE,ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,ABAERLKZ,QTYPLAN,ABARESMG, ABAQTYALLOCATE,ABAQTYRESERVE,ABAQTYRECEIVED,ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS"
                + ", ABAVKUPOS,ABAART,ABAVAR,ABAFARBE,ABAGROE,ABACOLORREF,ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,WAUEBM,WAFGRLFD,FSARTPRGR,FSKOLL)"
                    + " SELECT SEQ_ICC_MU.NEXTVAL,R.GAMANDANT,'G','N','  ','      ','   ','N',R.GAKG1*0.01,0,0,0,'V',R.GAAUFKRS,R.GAAUFLFD,R.GAAUFPOS,R.GAPOS,GAART,GAVAR,GAFARBE,substr( '                    ',1,7),GAFILLER,"
                    + "ABPART, ABPVAR,ABPFARBE,ABPGROE,FSABEZ,FSFFBEZ,LSLIEFNR,LSLIEFNA,'',0,FSARTPRGR,FSKOLL  FROM GAAUF R "
                    + " JOIN ABPOS ON ABPAUFKRS=GAAUFKRS AND ABPAUFLFD=GAAUFLFD AND ABPAUFPOS=GAAUFPOS"
                    + " LEFT JOIN FSSTAMM ON ABPART=FSART "
                    + " LEFT JOIN FSFARBEN ON FSFART=ABPART AND FSFFARBE=ABPFARBE "
                    + " LEFT JOIN LIEFDAT ON ABPLIEFNR=LSLIEFNR"
                    + " WHERE NOT EXISTS "
                    + " (SELECT 1 FROM ICC_ABAUFM M  WHERE R.GAAUFKRS=M.ABAVKAUFKRS AND R.GAAUFLFD=M.ABAVKAUFLFD AND R.GAAUFPOS=M.ABAVKAUFPOS AND TRIM(R.GAPOS)=TRIM(M.ABAVKUPOS))";
                    break;
                case 9:
                    or1.CommandText = "INSERT INTO ICC_ABAUFM(ABAID, ABAMANDANT, MTYPE,ABAAUFTYP, ABAAUFKRS, ABAAUFLFD, ABAAUFPOS, ABAAPOS, ABAART, ABAVAR, ABAFARBE, ABAGROE, SELLER, SELLERNAME, ABACOLORREF, ABAERLKZ, QTYPLAN,ABARESMG, ABAQTYRESERVE, ABAQTYALLOCATE, ABAQTYRECEIVED, ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS, ABAVKUPOS, WAFGRLFD, WAUEBM, FSARTPRGR, ABPART, ABPVAR, ABPFARBE, ABPGROE, FSABEZ, FSFFBEZ, LSLIEFNR, LSLIEFNA, ABANEUDAT)"
                    + " SELECT SEQ_ICC_MU.NEXTVAL,:ABAMANDANT,:MTYPE,:ABAAUFTYP,:ABAAUFKRS,:ABAAUFLFD,:ABAAUFPOS,:ABAAPOS,:ABAART,:ABAVAR,:ABAFARBE,:ABAGROE,:SELLER,:SELLERNAME,:ABACOLORREF,:ABAERLKZ,:ABARESMG,:ABARESMG,:ABAQTYRESERVE,:ABAQTYALLOCATE,:ABAQTYRECEIVED,:ABAVKAUFTYP,:ABAVKAUFKRS,:ABAVKAUFLFD,:ABAVKAUFPOS,:ABAVKUPOS,:WAFGRLFD,:WAUEBM,:FSARTPRGR,:ABPART,:ABPVAR,:ABPFARBE,:ABPGROE,:FSABEZ,:FSFFBEZ,:LSLIEFNR,:LSLIEFNA,:ABANEUDAT FROM DUAL ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("MTYPE", OracleType.NVarChar).Value = dwData["MTYPE"].ToString();
                    or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwData["ABAAUFTYP"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    or1.Parameters.Add("ABAAPOS", OracleType.NVarChar).Value = dwData["ABAAPOS"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("SELLER", OracleType.NVarChar).Value = dwData["SELLER"].ToString();
                    or1.Parameters.Add("SELLERNAME", OracleType.NVarChar).Value = dwData["SELLERNAME"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABAERLKZ", OracleType.NVarChar).Value = dwData["ABAERLKZ"].ToString();
                    or1.Parameters.Add("ABARESMG", OracleType.NVarChar).Value = dwData["ABARESMG"].ToString();
                    or1.Parameters.Add("ABAQTYRESERVE", OracleType.NVarChar).Value = dwData["ABAQTYRESERVE"].ToString();
                    or1.Parameters.Add("ABAQTYALLOCATE", OracleType.NVarChar).Value = dwData["ABAQTYALLOCATE"].ToString();
                    or1.Parameters.Add("ABAQTYRECEIVED", OracleType.NVarChar).Value = dwData["ABAQTYRECEIVED"].ToString();
                    or1.Parameters.Add("ABAVKAUFTYP", OracleType.NVarChar).Value = dwData["ABAVKAUFTYP"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    or1.Parameters.Add("ABAVKUPOS", OracleType.NVarChar).Value = dwData["ABAVKUPOS"].ToString();
                    or1.Parameters.Add("WAFGRLFD", OracleType.NVarChar).Value = dwData["WAFGRLFD"].ToString();
                    or1.Parameters.Add("WAUEBM", OracleType.NVarChar).Value = dwData["WAUEBM"].ToString();
                    or1.Parameters.Add("FSARTPRGR", OracleType.NVarChar).Value = dwData["FSARTPRGR"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABPVAR", OracleType.NVarChar).Value = dwData["ABPVAR"].ToString();
                    or1.Parameters.Add("ABPFARBE", OracleType.NVarChar).Value = dwData["ABPFARBE"].ToString();
                    or1.Parameters.Add("ABPGROE", OracleType.NVarChar).Value = dwData["ABPGROE"].ToString();
                    or1.Parameters.Add("FSABEZ", OracleType.NVarChar).Value = dwData["FSABEZ"].ToString();
                    or1.Parameters.Add("FSFFBEZ", OracleType.NVarChar).Value = dwData["FSFFBEZ"].ToString();
                    or1.Parameters.Add("LSLIEFNR", OracleType.NVarChar).Value = dwData["LSLIEFNR"].ToString();
                    or1.Parameters.Add("LSLIEFNA", OracleType.NVarChar).Value = dwData["LSLIEFNA"].ToString();
                    or1.Parameters.Add("ABANEUDAT", OracleType.NVarChar).Value = dwData["ABANEUDAT"].ToString();
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);

        }
    }
}
